package entity;


import java.io.Serializable;

/**
 * 分页
 */
public class Page implements Serializable {

	private static final long serialVersionUID = 1L;

	protected int pageSize = 10;// 默认一页十条数据

	protected int pageNumber = 1;// 默认当前页数为1

	private int startIndex;
	/**
	 * 是否分页 0：分页 1：不分 默认分页
	 */
	private int pagaFlag = 0;

	/**
	 * 排序字段
	 */
	private String orderBy;
	/**
	 * asc/desc
	 */
	private String order;

	public Page() {

	}

	public int getPagaFlag() {
		return pagaFlag;
	}

	public void setPagaFlag(int pagaFlag) {
		this.pagaFlag = pagaFlag;
	}

	public Page(int pageSize, int pageNumber) {
		if (pageSize > 0) {
			this.pageSize = pageSize;
		}
		if (pageNumber > 0) {
			this.pageNumber = pageNumber;
		}
	}

	public String getOrderBy() {
		return orderBy;
	}

	public void setOrderBy(String orderBy) {
		this.orderBy = orderBy;
	}

	public String getOrder() {
		return order;
	}

	public void setOrder(String order) {
		this.order = order;
	}

	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}

	public int getStartIndex() {
		this.startIndex = (this.pageNumber - 1) * pageSize;
		return this.startIndex;
	}
	public int getPageNumber() {
		return pageNumber;
	}

	public void setPageNumber(int pageNumber) {
		this.pageNumber = pageNumber;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageSize() {
		return pageSize;
	}

	@Override
	public String toString() {
		return "Page{" +
				"pageSize=" + pageSize +
				", pageNumber=" + pageNumber +
				", startIndex=" + startIndex +
				", pagaFlag=" + pagaFlag +
				", orderBy='" + orderBy + '\'' +
				", order='" + order + '\'' +
				'}';
	}
}
